package first.niuke.midding;

/**
 * @ClassName NC149
 * @description:
 * @author: 荣燊
 * @create: 2021-06-01 19:36
 **/
public class NC149 {
    public static int kmp (String S, String T) {
        // write code here
        int time = 0;
        for (int i=0; i<T.length(); i++) {
            int j = 0;
            int k = i;
            if (T.length() - i < S.length()) {
                break;
            }
            while (S.charAt(j) == T.charAt(k)) {
                if (j == S.length()-1) {
                    time++;
                    break;
                }
                j++;
                k++;
            }
        }
        return time;
    }

    public static void main(String[] args) {
        String s = "ababab";
        String t = "abababab";
        System.out.println(kmp(s, t));
    }
}
